--------------------------------------------------------------------------------------------------------
      name:  rep
       log:  /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict project/Co
> nflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/03_robustness_clean.log
  log type:  text
 opened on:   7 Dec 2025, 15:20:22
r; t=0.00 15:20:22

. 
. ***************************************************************
. * 1. SURVEY DATA (AFROBAROMETER R8) – LOCALITY & DATES
. ***************************************************************
. 
. use "${data}/Original_R8.dta", clear
r; t=1.39 15:20:23

. 
. *--------------------------------------------------------------
. * 1.1 Interview date and time within country
. *--------------------------------------------------------------
. * Numeric interview date
. gen intervdate = DATEINTR
r; t=0.00 15:20:23

. format intervdate %td
r; t=0.00 15:20:23

. label var intervdate "Interview date (numeric Stata date)"
r; t=0.00 15:20:23

. 
. * Fieldwork window (global)
. summ intervdate if !missing(intervdate)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
  intervdate |      7,594    22059.86    232.0189      21800      22479
r; t=0.00 15:20:23

. scalar field_start = r(min)
r; t=0.00 15:20:23

. scalar field_end   = r(max)
r; t=0.00 15:20:23

. 
. display "Fieldwork start: " %td field_start
Fieldwork start: 08sep2019
r; t=0.00 15:20:23

. display "Fieldwork end:   " %td field_end
Fieldwork end:   18jul2021
r; t=0.00 15:20:23

. 
. * Time since first interview within country
. egen min_intervdate = min(intervdate), by(COUNTRY)
r; t=0.01 15:20:23

. gen time_interviewed = intervdate - min_intervdate + 1 if !missing(intervdate)
r; t=0.00 15:20:23

. drop min_intervdate
r; t=0.00 15:20:23

. label var time_interviewed "Day of fieldwork within country (1 = first day)"
r; t=0.00 15:20:23

. 
. 
. ***************************************************************
. * 1.4 IDs AND STRINGS FOR MATCHING (R9)
. ***************************************************************
. * ID and locality
. encode COUNTRY, ge(country_name)
r; t=0.00 15:20:23

. decode country_name, gen(country1)
r; t=0.00 15:20:23

. * Unique respondent ID
. //drop id1
. gen id1 = _n
r; t=0.00 15:20:23

. * Locality and country for matching
. replace locality1 = trim(lower(locality1))
(0 real changes made)
r; t=0.00 15:20:23

. replace country1 = trim(lower(country1))
(0 real changes made)
r; t=0.00 15:20:23

. 
. * Combined locality + country
. 
. gen locality_country1 = locality1 + " " + country1
r; t=0.00 15:20:23

. sort id1 COUNTRY
r; t=0.00 15:20:23

. save "${data_new}/R8_c.dta", replace
(file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated data/R8_c.dta
    not found)
file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated data/R8_c.dta
    saved
r; t=0.00 15:20:23

. 
. ***************************************************************
. * 2. GTD – DATES, TIME_EXPOSED, LOCALITY STRINGS
. ***************************************************************
. 
. use "${data}/Original_gtd.dta", clear
r; t=0.58 15:20:24

. * Event date
. gen edate = mdy(imonth, iday, iyear)
r; t=0.00 15:20:24

. gen eventdate = edate
r; t=0.00 15:20:24

. format eventdate %td
r; t=0.00 15:20:24

. label var eventdate "Event date (GTD)"
r; t=0.00 15:20:24

. 
. * Unique ID and locality/country
. gen id2      = _n
r; t=0.00 15:20:24

. //gen locality2 = provstate
. //gen country2  = country_txt
. encode country_txt, ge(cntrynum)
r; t=0.00 15:20:24

. 
. gen locality_country2 = locality2 + " " + country2
r; t=0.00 15:20:24

. 
. sort id2 country_txt
r; t=0.00 15:20:24

. 
. save "${data_new}/gtd_c.dta", replace
(file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated
    data/gtd_c.dta not found)
file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated
    data/gtd_c.dta saved
r; t=0.00 15:20:24

. 
. ***************************************************************
. * 3. FUZZY MATCHING – matchit ON locality+country
. ***************************************************************
. 
. *--------------------------------------------------------------
. * 1. Get UNIQUE locality_country in R9
. *--------------------------------------------------------------
. use "${data_new}/R8_c.dta", clear
r; t=0.00 15:20:24

. 
. * Keep only the string we match on
. keep locality_country1
r; t=0.00 15:20:24

. 
. * One row per locality_country1
. duplicates drop locality_country1, force

Duplicates in terms of locality_country1

(7,532 observations deleted)
r; t=0.01 15:20:24

. 
. * ID required by matchit
. gen locid1 = _n
r; t=0.00 15:20:24

. 
. save "${data_new}/R8_loc_unique.dta", replace
(file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated
    data/R8_loc_unique.dta not found)
file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated
    data/R8_loc_unique.dta saved
r; t=0.00 15:20:24

. 
. 
. *--------------------------------------------------------------
. * 2. Get UNIQUE locality_country in ACLED
. *--------------------------------------------------------------
. use "${data_new}/gtd_c.dta", clear
r; t=0.00 15:20:24

. 
. * Keep the string + event id
. keep id2 locality_country2
r; t=0.00 15:20:24

. 
. 
. * ID required by matchit (for the using side)
. gen locid2 = _n
r; t=0.00 15:20:24

. 
. save "${data_new}/gtd_loc_unique.dta", replace
(file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated
    data/gtd_loc_unique.dta not found)
file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated
    data/gtd_loc_unique.dta saved
r; t=0.00 15:20:24

. 
. 
. *--------------------------------------------------------------
. * 3. Fuzzy match on unique localities (MUCH smaller)
. *--------------------------------------------------------------
. capture which matchit
r; t=0.00 15:20:24

. if _rc ssc install matchit
r; t=0.00 15:20:24

. 
. use "${data_new}/R8_loc_unique.dta", clear
r; t=0.00 15:20:24

. 
. matchit locid1 locality_country1 using "${data_new}/gtd_loc_unique.dta", ///
>     idu(locid2) txtu(locality_country2) threshold(0.9)
Matching current dataset with /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Co
> nflict project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated data/gtd_l
> oc_unique.dta
Similarity function: bigram
Loading USING file: /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict pro
> ject/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated data/gtd_loc_unique.
> dta
Indexing USING file.
0%
20%
40%
60%
80%
Done!
Computing results
        Percent completed ...   (search space saved by index so far)
        20%               ...   (26%)
        40%               ...   (28%)
        60%               ...   (30%)
        80%               ...   (28%)
        Done!
Total search space saved by index: 28%
r; t=0.09 15:20:24

. 
. save "${data_new}/loc_match.dta", replace
file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated
    data/loc_match.dta saved
r; t=0.00 15:20:24

. 
. *--------------------------------------------------------------
. * 4. Bring id2 back to locality level, keep BEST match per locality
. *--------------------------------------------------------------
. use "${data_new}/loc_match.dta", clear
r; t=0.00 15:20:24

. 
. * Attach id2 from the ACLED locality file
. merge m:1 locid2 using "${data_new}/gtd_loc_unique.dta", keep(match) nogen
(variable locid2 was byte, now float to accommodate using data's values)

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                                64  
    -----------------------------------------
r; t=0.01 15:20:24

. 
. * If matchit returns multiple candidate matches per locid1,
. * keep the one with the highest similarity score
. sort locid1 similscore
r; t=0.00 15:20:24

. by locid1: keep if _n == _N   // last = highest similscore
(2 observations deleted)
r; t=0.00 15:20:24

. 
. * Keep only what we need to merge back to individuals
. keep locality_country1 locality_country2 id2 similscore
r; t=0.00 15:20:24

. 
. save "${data_new}/loc_to_id2.dta", replace
file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated
    data/loc_to_id2.dta saved
r; t=0.00 15:20:24

. 
. 
. *--------------------------------------------------------------
. * 5. Merge event ID back to full R9 data
. *--------------------------------------------------------------
. use "${data_new}/R8_c.dta", clear
r; t=0.00 15:20:24

. 
. * One id2 per locality assigned to ALL respondents in that locality
. merge m:1 locality_country1 using "${data_new}/loc_to_id2.dta", ///
>     keep(master match) nogen

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                             7,594  
    -----------------------------------------
r; t=0.02 15:20:24

. 
. * Now each respondent has an ACLED event ID (id2)
. save "${data_new}/R8_with_id2.dta", replace
(file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated
    data/R8_with_id2.dta not found)
file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated
    data/R8_with_id2.dta saved
r; t=0.01 15:20:24

. 
. 
. ***************************************************************
. * 4. FINAL MERGE: R8 + GTD EVENTS
. ***************************************************************
. 
. * Start from respondent data with matched id2
. use "${data_new}/R8_with_id2.dta", clear
r; t=0.00 15:20:24

. 
. * Merge GTD information by id2
. merge m:1 id2 using "${data_new}/gtd_c.dta", keep(match) nogen
(variable locality_country1 was str26, now str56 to accommodate using data's values)

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                             7,594  
    -----------------------------------------
r; t=0.00 15:20:24

. 
. save "${data_new}/finaldata_merge.dta", replace
(file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated
    data/finaldata_merge.dta not found)
file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated
    data/finaldata_merge.dta saved
r; t=0.00 15:20:24

. 
. 
. * Time difference between interview and matched event (days)
. gen tdiff = intervdate - eventdate if !missing(intervdate) & !missing(eventdate)
r; t=0.00 15:20:24

. label var tdiff "Days between interview and matched event"
r; t=0.00 15:20:24

. summ tdiff

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
       tdiff |      7,594    81.52515    308.5954       -449        686
r; t=0.00 15:20:24

. 
. * Post-event indicator (example)
. gen time_zero = (tdiff > 0) if !missing(tdiff)
r; t=0.00 15:20:24

. label var time_zero "Interview after matched event (1 = yes)"
r; t=0.00 15:20:24

. 
. * Survey year (for FE) – create only if missing
. capture confirm variable surveyyear
r; t=0.00 15:20:24

. if _rc {
.     gen surveyyear = year(DATEINTR)
r; t=0.00 15:20:24
.     label var surveyyear "Survey year (from DATEINTR)"
r; t=0.00 15:20:24
. }
r; t=0.00 15:20:24

. 
. * 'year' variable for country-year merges – create only if missing
. capture confirm variable year
r; t=0.00 15:20:24

. if _rc {
.     capture confirm variable surveyyear
r; t=0.00 15:20:24
.     if !_rc {
.         gen year = surveyyear
r; t=0.00 15:20:24
.     }
r; t=0.00 15:20:24
.     else {
.         gen year = year(DATEINTR)
r; t=0.00 15:20:24
.     }
r; t=0.00 15:20:24
. }
r; t=0.00 15:20:24

. 
. * Numeric country ID (if not already there)
. capture confirm variable cntrynum
r; t=0.00 15:20:24

. if _rc {
.     encode country, gen(cntrynum)
r; t=0.00 15:20:24
. }
r; t=0.00 15:20:24

. 
. save "${data_new}/finaldata2.dta", replace
(file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated
    data/finaldata2.dta not found)
file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/output/Generated
    data/finaldata2.dta saved
r; t=0.00 15:20:24

. ***************************************************************
. * 7. DEMOGRAPHICS – R8 CODING
. ***************************************************************
. 
. * Age
. tab Q1, nolabel

Respondent' |
      s age |      Freq.     Percent        Cum.
------------+-----------------------------------
         18 |        251        3.31        3.31
         19 |        237        3.12        6.43
         20 |        323        4.26       10.69
         21 |        169        2.23       12.92
         22 |        297        3.91       16.83
         23 |        194        2.56       19.39
         24 |        179        2.36       21.74
         25 |        360        4.74       26.49
         26 |        173        2.28       28.77
         27 |        236        3.11       31.88
         28 |        285        3.76       35.64
         29 |        172        2.27       37.90
         30 |        401        5.28       43.19
         31 |         96        1.27       44.45
         32 |        254        3.35       47.80
         33 |        140        1.85       49.64
         34 |        102        1.34       50.99
         35 |        296        3.90       54.89
         36 |        177        2.33       57.22
         37 |        126        1.66       58.88
         38 |        177        2.33       61.22
         39 |        110        1.45       62.66
         40 |        322        4.24       66.91
         41 |         69        0.91       67.82
         42 |        165        2.17       69.99
         43 |         93        1.23       71.22
         44 |         78        1.03       72.25
         45 |        277        3.65       75.90
         46 |         75        0.99       76.88
         47 |         98        1.29       78.18
         48 |        133        1.75       79.93
         49 |         66        0.87       80.80
         50 |        189        2.49       83.29
         51 |         58        0.76       84.05
         52 |         90        1.19       85.24
         53 |         60        0.79       86.03
         54 |         49        0.65       86.68
         55 |        108        1.42       88.10
         56 |         51        0.67       88.77
         57 |         40        0.53       89.30
         58 |         83        1.09       90.39
         59 |         40        0.53       90.92
         60 |        123        1.62       92.54
         61 |         32        0.42       92.96
         62 |         47        0.62       93.58
         63 |         44        0.58       94.16
         64 |         23        0.30       94.46
         65 |         61        0.80       95.27
         66 |         35        0.46       95.73
         67 |         23        0.30       96.03
         68 |         32        0.42       96.45
         69 |         21        0.28       96.73
         70 |         79        1.04       97.77
         71 |         22        0.29       98.06
         72 |         17        0.22       98.29
         73 |         13        0.17       98.46
         74 |         15        0.20       98.66
         75 |         24        0.32       98.97
         76 |         11        0.14       99.12
         77 |          5        0.07       99.18
         78 |          8        0.11       99.29
         79 |          1        0.01       99.30
         80 |         26        0.34       99.64
         81 |          4        0.05       99.70
         83 |          1        0.01       99.71
         84 |          2        0.03       99.74
         85 |          7        0.09       99.83
         86 |          1        0.01       99.84
         87 |          2        0.03       99.87
         88 |          1        0.01       99.88
         89 |          1        0.01       99.89
         90 |          2        0.03       99.92
         92 |          1        0.01       99.93
         95 |          1        0.01       99.95
         96 |          1        0.01       99.96
         98 |          1        0.01       99.97
        102 |          1        0.01       99.99
        112 |          1        0.01      100.00
------------+-----------------------------------
      Total |      7,588      100.00
r; t=0.00 15:20:24

. replace Q1 = . if Q1 == 998 | Q1 == 999
(0 real changes made)
r; t=0.00 15:20:24

. clonevar age = Q1
(6 missing values generated)
r; t=0.00 15:20:24

. label var age "Respondent's age"
r; t=0.00 15:20:24

. 
. * Gender (Q101)
. recode Q101 (1 = 0) (2 = 1) (9999 = .), gen(gender)
(7,594 differences between Q101 and gender)
r; t=0.00 15:20:24

. label define gender_lbl 0 "Male" 1 "Female", replace
r; t=0.00 15:20:24

. label values gender gender_lbl
r; t=0.00 15:20:24

. label var gender "Gender of respondent"
r; t=0.00 15:20:24

. tab gender

  Gender of |
 respondent |      Freq.     Percent        Cum.
------------+-----------------------------------
       Male |      3,801       50.05       50.05
     Female |      3,793       49.95      100.00
------------+-----------------------------------
      Total |      7,594      100.00
r; t=0.00 15:20:24

. 
. * Race (Q102 -> race; plus grouped race_group)
. recode Q102 ///
>     (1 = 1) ///
>     (2 = 2) ///
>     (3 = 3) ///
>     (4 = 4) ///
>     (5 = 5) ///
>     (6 = 5) ///
>     (9995 = 6) ///
>     (9999 = .), gen(race)
(3 differences between Q102 and race)
r; t=0.00 15:20:24

. 
. label define race_lbl ///
>     1 "Black / African" ///
>     2 "White / European" ///
>     3 "Coloured / Mixed race" ///
>     4 "Arab / Lebanese / North African" ///
>     5 "Asian (South & East Asian)" ///
>     6 "Other", replace
r; t=0.00 15:20:24

. label values race race_lbl
r; t=0.00 15:20:24

. label var race "Race of respondent (grouped)"
r; t=0.00 15:20:24

. 
. recode race (1 = 1) (2 = 2) (3/6 = 3), gen(race_group)
(42 differences between race and race_group)
r; t=0.00 15:20:24

. label define race_group_lbl ///
>     1 "Black / African" ///
>     2 "White / European" ///
>     3 "Others", replace
r; t=0.00 15:20:24

. label values race_group race_group_lbl
r; t=0.00 15:20:24

. tab race_group

  RECODE of race |
        (Race of |
      respondent |
      (grouped)) |      Freq.     Percent        Cum.
-----------------+-----------------------------------
 Black / African |      7,073       93.15       93.15
White / European |        135        1.78       94.93
          Others |        385        5.07      100.00
-----------------+-----------------------------------
           Total |      7,593      100.00
r; t=0.00 15:20:24

. 
. * Religion (Q98A)
. recode Q98A ///
>     (0 = 5) ///
>     (1 = 2) ///
>     (2 = 2) ///
>     (3 = 3) ///
>     (4 = 3) ///
>     (5/17 = 3) ///
>     (18/24 = 1) ///
>     (25 = 4) ///
>     (26 = 5) ///
>     (27 = 5) ///
>     (28 = 5) ///
>     (29 = 5) ///
>     (30/33 = 3) ///
>     (34 = 5) ///
>     (100 = 2) ///
>     (260 = 3) ///
>     (261 = 3) ///
>     (300 = 3) ///
>     (340 = 3) ///
>     (460 = 3) ///
>     (462 = 3) ///
>     (463 = 3) ///
>     (660 = 5) ///
>     (742 = 3) ///
>     (820 = 3) ///
>     (821 = 3) ///
>     (900 = 5) ///
>     (1260 = 5) ///
>     (1340 = 5) ///
>     (1750 = 5) ///
>     (1751/1757 = 3) ///
>     (1758 = 5) ///
>     (9995 = 5) ///
>     (9998 = .) ///
>     (9999 = .) ///
>     (-1 = .), gen(religion)
(6,428 differences between Q98A and religion)
r; t=0.02 15:20:24

. 
. label define religion_lbl ///
>     1 "Muslim" ///
>     2 "Christian" ///
>     3 "Protestant (other Christian)" ///
>     4 "Traditional/Ethnic religion" ///
>     5 "Others (incl. None)", replace
r; t=0.00 15:20:24

. label values religion religion_lbl
r; t=0.00 15:20:24

. label var religion "Religion of respondent"
r; t=0.00 15:20:24

. tab religion

      Religion of respondent |      Freq.     Percent        Cum.
-----------------------------+-----------------------------------
                      Muslim |      3,089       40.89       40.89
                   Christian |      2,048       27.11       68.00
Protestant (other Christian) |      1,783       23.60       91.61
 Traditional/Ethnic religion |         86        1.14       92.75
         Others (incl. None) |        548        7.25      100.00
-----------------------------+-----------------------------------
                       Total |      7,554      100.00
r; t=0.00 15:20:24

. 
. * Urban–rural (URBRUR)
. recode URBRUR (1 = 1) (2 3 = 2), gen(urban_rural)
(0 differences between URBRUR and urban_rural)
r; t=0.00 15:20:24

. label define urban_rural_lbl 1 "Urban" 2 "Rural", replace
r; t=0.00 15:20:24

. label values urban_rural urban_rural_lbl
r; t=0.00 15:20:24

. label var urban_rural "Urban-Rural"
r; t=0.00 15:20:24

. 
. * Ethnic group (Q81)
. recode Q81 (-1 9990 9994 9995 9998 9999 = .), gen(ethnic)
(319 differences between Q81 and ethnic)
r; t=0.00 15:20:24

. label var ethnic "Ethnic group of respondent"
r; t=0.00 15:20:24

. 
. * Education (Q97 -> recoded_education, educ_group)
. recode Q97 ///
>     (0 = 0) ///
>     (1 = 1) ///
>     (2 = 2) ///
>     (3 = 3) ///
>     (4 = 4) ///
>     (5 = 5) ///
>     (6 = 6) ///
>     (7 = 7) ///
>     (8 = 8) ///
>     (9 = 9) ///
>     (-1 98 = .) ///
>     (99 = .), gen(recoded_education)
(34 differences between Q97 and recoded_education)
r; t=0.01 15:20:24

. 
. label define education_lbl ///
>     0 "No formal schooling" ///
>     1 "Informal schooling only" ///
>     2 "Some primary schooling" ///
>     3 "Primary school completed" ///
>     4 "Some secondary/high school" ///
>     5 "Secondary/high school completed" ///
>     6 "Post-secondary, non-university" ///
>     7 "Some university" ///
>     8 "University completed" ///
>     9 "Post-graduate", replace
r; t=0.00 15:20:24

. label values recoded_education education_lbl
r; t=0.00 15:20:24

. label var recoded_education "Re-coded education levels"
r; t=0.00 15:20:24

. 
. recode recoded_education (0 1 2 = 1) (3 4 = 2) (5 6 7 = 3) (8 9 = 4), gen(educ_group)
(7,244 differences between recoded_education and educ_group)
r; t=0.01 15:20:24

. label define educ_group_lbl ///
>     1 "Below primary" ///
>     2 "Primary" ///
>     3 "Secondary" ///
>     4 "University", replace
r; t=0.00 15:20:24

. label values educ_group educ_group_lbl
r; t=0.00 15:20:24

. label var educ_group "Education level"
r; t=0.00 15:20:24

. tab educ_group

    Education |
        level |      Freq.     Percent        Cum.
--------------+-----------------------------------
Below primary |      3,133       41.44       41.44
      Primary |      1,815       24.01       65.45
    Secondary |      2,144       28.36       93.81
   University |        468        6.19      100.00
--------------+-----------------------------------
        Total |      7,560      100.00
r; t=0.00 15:20:24

. 
. * Employment status (Q95A)
. recode Q95A ///
>     (0 = 0) ///
>     (1 = 1) ///
>     (2 = 2) ///
>     (3 = 3) ///
>     (8 = .) ///
>     (9 = .) ///
>     (-1 = .), gen(recoded_employment)
(33 differences between Q95A and recoded_employment)
r; t=0.00 15:20:24

. 
. label define employment_status_lbl ///
>     0 "No (not looking)" ///
>     1 "No (looking)" ///
>     2 "Yes, part time" ///
>     3 "Yes, full time", replace
r; t=0.00 15:20:24

. label values recoded_employment employment_status_lbl
r; t=0.00 15:20:24

. label var recoded_employment "Re-coded employment status"
r; t=0.00 15:20:24

. 
. recode recoded_employment (0 1 = 1) (2 = 2) (3 = 3), gen(emp_group)
(3,152 differences between recoded_employment and emp_group)
r; t=0.00 15:20:24

. label define emp_group_lbl ///
>     1 "Not employed" ///
>     2 "Part-time" ///
>     3 "Full-time", replace
r; t=0.00 15:20:24

. label values emp_group emp_group_lbl
r; t=0.00 15:20:24

. label var emp_group "Employment status"
r; t=0.00 15:20:24

. tab emp_group

  Employment |
      status |      Freq.     Percent        Cum.
-------------+-----------------------------------
Not employed |      4,873       64.45       64.45
   Part-time |        775       10.25       74.70
   Full-time |      1,913       25.30      100.00
-------------+-----------------------------------
       Total |      7,561      100.00
r; t=0.00 15:20:24

. 
. * Safety walking in neighbourhood (Q8A)
. recode Q8A ///
>     (0 = 0) ///
>     (1 = 1) ///
>     (2 = 2) ///
>     (3 = 3) ///
>     (4 = 4) ///
>     (8 = .) ///
>     (9 = .), gen(recoded_Q8A)
(20 differences between Q8A and recoded_Q8A)
r; t=0.00 15:20:24

. 
. label define unsafe_walk_lbl ///
>     0 "Never" ///
>     1 "Just once or twice" ///
>     2 "Several times" ///
>     3 "Many times" ///
>     4 "Always", replace
r; t=0.00 15:20:24

. label values recoded_Q8A unsafe_walk_lbl
r; t=0.00 15:20:24

. label var recoded_Q8A "Feeling unsafe walking in neighbourhood"
r; t=0.00 15:20:24

. 
. recode recoded_Q8A (0 1 = 1) (2 = 2) (3 4 = 3), gen(safety_group)
(4,543 differences between recoded_Q8A and safety_group)
r; t=0.00 15:20:24

. label define safety_group_lbl ///
>     1 "Never or rarely" ///
>     2 "Occasionally" ///
>     3 "Frequently", replace
r; t=0.00 15:20:24

. label values safety_group safety_group_lbl
r; t=0.00 15:20:24

. label var safety_group "Safety status"
r; t=0.00 15:20:24

. gen safety = safety_group
(20 missing values generated)
r; t=0.00 15:20:24

. 
. * Fear crime at home (Q8B)
. recode Q8B ///
>     (0 = 0) ///
>     (1 = 1) ///
>     (2 = 2) ///
>     (3 = 3) ///
>     (4 = 4) ///
>     (8 = .) ///
>     (9 = .), gen(recoded_Q8B)
(13 differences between Q8B and recoded_Q8B)
r; t=0.00 15:20:24

. 
. label define fear_crime_home_lbl ///
>     0 "Never" ///
>     1 "Just once or twice" ///
>     2 "Several times" ///
>     3 "Many times" ///
>     4 "Always", replace
r; t=0.00 15:20:24

. label values recoded_Q8B fear_crime_home_lbl
r; t=0.00 15:20:24

. label var recoded_Q8B "Fearing crime at home (original)"
r; t=0.00 15:20:24

. 
. recode recoded_Q8B (0 1 = 1) (2 = 2) (3 4 = 3), gen(fearing_crime)
(4,955 differences between recoded_Q8B and fearing_crime)
r; t=0.00 15:20:24

. label define fearing_crime_lbl ///
>     1 "Never or rarely" ///
>     2 "Occasionally" ///
>     3 "Frequently", replace
r; t=0.00 15:20:24

. label values fearing_crime fearing_crime_lbl
r; t=0.00 15:20:24

. label var fearing_crime "Fearing crime at home"
r; t=0.00 15:20:24

. tab fearing_crime

  Fearing crime |
        at home |      Freq.     Percent        Cum.
----------------+-----------------------------------
Never or rarely |      5,380       70.97       70.97
   Occasionally |        979       12.91       83.88
     Frequently |      1,222       16.12      100.00
----------------+-----------------------------------
          Total |      7,581      100.00
r; t=0.00 15:20:24

. 
. * Discussing politics (Q9)
. recode Q9 ///
>     (0 = 0) ///
>     (1 = 1) ///
>     (2 = 2) ///
>     (8 = .) ///
>     (9 = .), gen(recoded_Q9)
(44 differences between Q9 and recoded_Q9)
r; t=0.00 15:20:24

. 
. label define politics_lbl ///
>     0 "Never" ///
>     1 "Occasionally" ///
>     2 "Frequently", replace
r; t=0.00 15:20:24

. label values recoded_Q9 politics_lbl
r; t=0.00 15:20:24

. label var recoded_Q9 "Discussing politics (original)"
r; t=0.00 15:20:24

. 
. recode recoded_Q9 (0 = 0) (1 = 1) (2 = 2), gen(discuss_politics)
(0 differences between recoded_Q9 and discuss_politics)
r; t=0.00 15:20:24

. label define discuss_politics_lbl ///
>     0 "Never discuss politics" ///
>     1 "Occasionally discuss politics" ///
>     2 "Frequently discuss politics", replace
r; t=0.00 15:20:24

. label values discuss_politics discuss_politics_lbl
r; t=0.00 15:20:24

. label var discuss_politics "Frequency of discussing politics (grouped)"
r; t=0.00 15:20:24

. tab discuss_politics

      Frequency of discussing |
           politics (grouped) |      Freq.     Percent        Cum.
------------------------------+-----------------------------------
       Never discuss politics |      2,669       35.35       35.35
Occasionally discuss politics |      3,397       44.99       80.34
  Frequently discuss politics |      1,484       19.66      100.00
------------------------------+-----------------------------------
                        Total |      7,550      100.00
r; t=0.00 15:20:24

. 
. * EA-level infrastructure
. replace EA_FAC_C = . if EA_FAC_C == 9
(0 real changes made)
r; t=0.00 15:20:24

. replace EA_SEC_B = . if EA_SEC_B == 9
(0 real changes made)
r; t=0.00 15:20:24

. replace EA_SVC_B = . if EA_SVC_B == 9
(0 real changes made)
r; t=0.00 15:20:24

. 
. misstable summarize EA_FAC_C EA_SEC_B EA_SVC_B
                                                               Obs<.
                                                +------------------------------
               |                                | Unique
      Variable |     Obs=.     Obs>.     Obs<.  | values        Min         Max
  -------------+--------------------------------+------------------------------
      EA_FAC_C |       124               7,470  |      2          0           1
      EA_SEC_B |         8               7,586  |      2          0           1
      EA_SVC_B |        28               7,566  |      2          0           1
  -----------------------------------------------------------------------------
r; t=0.03 15:20:24

. 
. gen police_station = (EA_FAC_C == 1)
r; t=0.00 15:20:24

. gen soldiers_army  = (EA_SEC_B == 1)
r; t=0.00 15:20:24

. gen piped_water    = (EA_SVC_B == 1)
r; t=0.00 15:20:24

. 
. label var police_station "Police station in town/village"
r; t=0.00 15:20:24

. label var soldiers_army  "Soldiers/army in town/village"
r; t=0.00 15:20:24

. label var piped_water    "Piped water system in town/village"
r; t=0.00 15:20:24

. 
. ***************************************************************
. * 8. OUTCOME VARIABLES – DEMOCRACY & AUTHORITARIANISM (R8)
. ***************************************************************
. 
. * Support for democracy (Q21)
. recode Q21 ///
>     (1 = 1) ///
>     (2 = 2) ///
>     (3 = 3) ///
>     (8 = .) ///
>     (9 = .), gen(recoded_Q21)
(163 differences between Q21 and recoded_Q21)
r; t=0.00 15:20:24

. 
. label define democracy_support_lbl ///
>     1 "It doesn't matter what kind of government" ///
>     2 "Non-democratic government can be preferable" ///
>     3 "Democracy is preferable", replace
r; t=0.00 15:20:24

. label values recoded_Q21 democracy_support_lbl
r; t=0.00 15:20:24

. label var recoded_Q21 "Support for democracy (original)"
r; t=0.00 15:20:24

. 
. recode recoded_Q21 (1 2 = 1) (3 = 2), gen(support_democracy_group)
(6,253 differences between recoded_Q21 and support_democracy_group)
r; t=0.00 15:20:24

. label define support_democracy_group_lbl ///
>     1 "Against democracy or indifferent" ///
>     2 "Support democracy", replace
r; t=0.00 15:20:24

. label values support_democracy_group support_democracy_group_lbl
r; t=0.00 15:20:24

. label var support_democracy_group "Support for democracy (grouped)"
r; t=0.00 15:20:24

. 
. * Extent of democracy (Q36)
. recode Q36 ///
>     (1 = 1) ///
>     (2 = 2) ///
>     (3 = 3) ///
>     (4 = 4) ///
>     (8 = .) ///
>     (9 = .) ///
>     (98 = .), gen(recoded_Q36)
(208 differences between Q36 and recoded_Q36)
r; t=0.00 15:20:24

. 
. label define democracy_extent_lbl ///
>     1 "Not a democracy" ///
>     2 "A democracy with major problems" ///
>     3 "A democracy with minor problems" ///
>     4 "A full democracy", replace
r; t=0.00 15:20:24

. label values recoded_Q36 democracy_extent_lbl
r; t=0.00 15:20:24

. label var recoded_Q36 "Extent of democracy (original)"
r; t=0.00 15:20:24

. 
. recode recoded_Q36 (1 = 1) (2 3 = 2) (4 = 3), gen(democracy_group)
(3,787 differences between recoded_Q36 and democracy_group)
r; t=0.00 15:20:24

. label define democracy_group_lbl ///
>     1 "Not a democracy" ///
>     2 "Democracy with problems" ///
>     3 "Full democracy", replace
r; t=0.00 15:20:24

. label values democracy_group democracy_group_lbl
r; t=0.00 15:20:24

. label var democracy_group "Extent of democracy (grouped)"
r; t=0.00 15:20:24

. 
. * Authoritarian alternatives (Q20A/B/C)
. recode Q20B ///
>     (1 = 1) ///
>     (2 = 2) ///
>     (3 = 3) ///
>     (4 = 4) ///
>     (5 = 5) ///
>     (8 = .) ///
>     (9 = .), gen(recoded_Q20B)
(148 differences between Q20B and recoded_Q20B)
r; t=0.00 15:20:24

. 
. label define military_rule_rejection_lbl ///
>     1 "Strongly disapprove" ///
>     2 "Disapprove" ///
>     3 "Neither approve nor disapprove" ///
>     4 "Approve" ///
>     5 "Strongly approve", replace
r; t=0.00 15:20:24

. label values recoded_Q20B military_rule_rejection_lbl
r; t=0.00 15:20:24

. label var recoded_Q20B "Rejection of military rule (original)"
r; t=0.00 15:20:24

. 
. recode recoded_Q20B (1 2 = 3) (3 = 2) (4 5 = 1), gen(rejection_military_rule)
(7,446 differences between recoded_Q20B and rejection_military_rule)
r; t=0.00 15:20:24

. label define rejection_military_rule_lbl ///
>     1 "Support military rule" ///
>     2 "Neutral" ///
>     3 "Reject military rule", replace
r; t=0.00 15:20:24

. label values rejection_military_rule rejection_military_rule_lbl
r; t=0.00 15:20:24

. label var rejection_military_rule "Rejection of military rule (grouped)"
r; t=0.00 15:20:24

. 
. recode Q20A ///
>     (1 = 1) ///
>     (2 = 2) ///
>     (3 = 3) ///
>     (4 = 4) ///
>     (5 = 5) ///
>     (8 = .) ///
>     (9 = .), gen(recoded_Q20A)
(112 differences between Q20A and recoded_Q20A)
r; t=0.00 15:20:24

. 
. label define one_party_rule_rejection_lbl ///
>     1 "Strongly disapprove" ///
>     2 "Disapprove" ///
>     3 "Neither approve nor disapprove" ///
>     4 "Approve" ///
>     5 "Strongly approve", replace
r; t=0.00 15:20:24

. label values recoded_Q20A one_party_rule_rejection_lbl
r; t=0.00 15:20:24

. label var recoded_Q20A "Rejection of one-party rule (original)"
r; t=0.00 15:20:24

. 
. recode recoded_Q20A (1 2 = 3) (3 = 2) (4 5 = 1), gen(rejection_one_party_rule)
(7,482 differences between recoded_Q20A and rejection_one_party_rule)
r; t=0.00 15:20:24

. label define rejection_one_party_rule_lbl ///
>     1 "Support one-party rule" ///
>     2 "Neutral" ///
>     3 "Reject one-party rule", replace
r; t=0.00 15:20:24

. label values rejection_one_party_rule rejection_one_party_rule_lbl
r; t=0.00 15:20:24

. label var rejection_one_party_rule "Rejection of one-party rule (grouped)"
r; t=0.00 15:20:24

. 
. recode Q20C ///
>     (1 = 1) ///
>     (2 = 2) ///
>     (3 = 3) ///
>     (4 = 4) ///
>     (5 = 5) ///
>     (8 = .) ///
>     (9 = .), gen(recoded_Q20C)
(204 differences between Q20C and recoded_Q20C)
r; t=0.00 15:20:24

. 
. label define one_man_rule_rejection_lbl ///
>     1 "Strongly disapprove" ///
>     2 "Disapprove" ///
>     3 "Neither approve nor disapprove" ///
>     4 "Approve" ///
>     5 "Strongly approve", replace
r; t=0.00 15:20:24

. label values recoded_Q20C one_man_rule_rejection_lbl
r; t=0.00 15:20:24

. label var recoded_Q20C "Rejection of one-man rule (original)"
r; t=0.00 15:20:24

. 
. recode recoded_Q20C (1 2 = 3) (3 = 2) (4 5 = 1), gen(rejection_one_man_rule)
(7,390 differences between recoded_Q20C and rejection_one_man_rule)
r; t=0.00 15:20:24

. label define rejection_one_man_rule_lbl ///
>     1 "Support one-man rule" ///
>     2 "Neutral" ///
>     3 "Reject one-man rule", replace
r; t=0.00 15:20:24

. label values rejection_one_man_rule rejection_one_man_rule_lbl
r; t=0.00 15:20:24

. label var rejection_one_man_rule "Rejection of one-man rule (grouped)"
r; t=0.00 15:20:24

. 
. ***************************************************************
. * 9. COMPOSITE & FINAL VARIABLES
. ***************************************************************
. 
. * Composite: rejection of authoritarian alternatives
. egen auth_support = rowmean(rejection_military_rule ///
>                             rejection_one_party_rule ///
>                             rejection_one_man_rule)
(67 missing values generated)
r; t=0.00 15:20:24

. label var auth_support "Rejection of authoritarian alternatives"
r; t=0.00 15:20:24

. summ auth_support

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
auth_support |      7,527    2.519596    .5855483          1          3
r; t=0.00 15:20:24

. 
. * Main DV convenience copies
. gen demo_support     = support_democracy_group
(163 missing values generated)
r; t=0.00 15:20:24

. gen demo_rated       = democracy_group
(208 missing values generated)
r; t=0.00 15:20:24

. 
. * Outcomes macro for robustness regressions (only existing vars)
. global outcomes_groups demo_support auth_support 
r; t=0.00 15:20:24

. 
. ***************************************************************
. * 10. SAVE CLEANED ROBUSTNESS DATA
. ***************************************************************
. 
. save "${data}/R8_final.dta", replace
file /Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict
    project/Conflict-Nigeria/Observationaldata/R9-Acled/JCR replication/Original data/R8_final.dta
    saved
r; t=0.01 15:20:24

. ***************************************************************
. * END OF DO-FILE
. ***************************************************************
. 
end of do-file

r; t=3.39 15:20:24
. do "/Users/souleymane.yameogo/Library/CloudStorage/Dropbox/WP3_OnlineCivics/Conflict project/Conflict-
> Nigeria/Observationaldata/R9-Acled/JCR replication/04_robustness_analysis.do"

. ***************************************************************
. * 04_robustness_analysis.do
. * Afrobarometer Round 8 x GTD – Robustness Regressions
. // Project: "The Impact of Terrorism on Democratic Support in Africa"
. ***************************************************************
. 
. version 18.0
r; t=0.00 15:20:29

. clear all
r; t=0.09 15:20:29

. set more off
r; t=0.00 15:20:29

. set rmsg on
r; t=0.00 15:20:29

. cap set scheme plotplain
r; t=0.00 15:20:29

. 
. * --------------------------------------------------------------
. * Project root (robust to where the do-file is run from)
. * --------------------------------------------------------------
. local thisdo = c(filename)
r; t=0.00 15:20:29

. 
. * Fallback if c(filename) is empty (rare)
. if "`thisdo'" == "" {
.     global root "`c(pwd)'"
r; t=0.00 15:20:29
. }
r; t=0.00 15:20:29

. else {
.     * Directory containing this do-file
.     local dodir : dirname "`thisdo'"
r; t=0.00 15:20:29
.     * Project root is parent of /dofile
.     local root  : dirname "`dodir'"
r; t=0.00 15:20:29
.     global root "`root'"
r; t=0.00 15:20:29
. }
r; t=0.00 15:20:29

. 
. * If someone runs from inside /dofile (extra safety)
. if substr("${root}", -6, 6) == "dofile" {
.     global root = substr("${root}", 1, length("${root}")-6)
r; t=0.00 15:20:29
. }
r; t=0.00 15:20:29

. 
. 
. *--------------------------------------------------------------
. * 0. PATHS (relative; no machine-specific paths)
. *--------------------------------------------------------------
. 
. global data   "${root}/Original data"
r; t=0.00 15:20:29

. global do     "${root}/dofile"
r; t=0.00 15:20:29

. global out    "${root}/output"
r; t=0.00 15:20:29

. global table  "${out}/tables"
r; t=0.00 15:20:29

. global graph  "${out}/graphs"
r; t=0.00 15:20:29

. global data_new  "${out}/Generated data"
r; t=0.00 15:20:29

. 
. cap mkdir "${out}"
r; t=0.00 15:20:29

. cap mkdir "${table}"
r; t=0.00 15:20:29

. cap mkdir "${graph}"
r; t=0.00 15:20:29

. cap mkdir "${data_new}"
r; t=0.00 15:20:29

. 
. 
. cap log close _all
